package day230424;

import java.util.Scanner;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/4/24 9:01
 * 美国节日
 * 基准值为 0000 年 1 月 1 日 星期 7
 */
public class Main01 {

    // 存储平年每月的天数 index = 0 表示前 1 月的天数
    // index = 1, 则表示, 前2月的天数
    static int[] days = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};

    // 判断是否为闰年
    private static boolean itSALeapYear(int y) {
        return (y % 400 == 0) || (y % 4 == 0 && y % 100 != 0);
    }

    // 计算指定日期距离基准值的偏移量天数的同余数(%7)
    private static int diff(int y, int m, int d) {
        int theDayForThisYear = d; // 计算今年的第几天
        if (m >= 2) {
            theDayForThisYear += days[m-2];
        }
        if (m > 2 && itSALeapYear(y)) {
            // 如果是闰年
            theDayForThisYear += 1;
        }
//        int countLeapYear = 0;
//        for (int i = 1; i < y; i++) {
//            if (itSALeapYear(i)) {
//                countLeapYear++;
//            }
//        }
        // 偏移量为 365(y-1) + (y-1)/400 - (y-1)/100 + (y-1)/4 + theDayForThisYear
        // [1, y) 之间过的年数 * 365 + 闰年个数 + 当年天数
        return ((y-1) + (y-1)/400 - (y-1)/100 + (y-1)/4 + theDayForThisYear) % 7;
//        return (365 * (y-1) + countLeapYear + theDayForThisYear) % 7;
    }

    // 根据指定日期计算星期几
    private static int getWeek(int y, int m, int d) {
        int week = diff(y, m, d);
        if (week == 0) {
            return 7; // 7 代表星期天
        }
        return week;
    }

    // 根据m月第一天是星期几推算当月的第n个星期e是多少号
    // 传入的w为当月第一天为星期几
    private static int lunarFirstEstimate(int w, int n, int e) {
        return 1 + (n - 1) * 7 + (7 - w + e) % 7;
    }

    // 单独推算五月最后一个星期一
    private static int cMay(int w) {
        // 根据 6 月 1 是星期几 当作 5 月 32 日, 推算上一个星期 1 是几号
        if (w == 1) {
            return 32 - 7;
        }
        return 32 - (w - 1);
    }

    // 主方法
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int year = scan.nextInt();
            System.out.printf("%d-01-01\n", year);
            int week = getWeek(year, 1, 1);
            System.out.printf("%d-01-%02d\n", year, lunarFirstEstimate(week, 3, 1));
            week = getWeek(year, 2, 1);
            System.out.printf("%d-02-%02d\n", year, lunarFirstEstimate(week, 3, 1));
            week = getWeek(year, 6, 1);
            System.out.printf("%d-05-%02d\n", year, cMay(week));
            System.out.printf("%d-07-04\n", year);
            week = getWeek(year, 9, 1);
            System.out.printf("%d-09-%02d\n", year, lunarFirstEstimate(week, 1, 1));
            week = getWeek(year, 11, 1);
            System.out.printf("%d-11-%02d\n", year, lunarFirstEstimate(week, 4, 4));
            System.out.printf("%d-12-25\n", year);
            System.out.println();
        }
        scan.close();
    }
}
